package com.ydzh.kfqgwvisitor.util;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;

/**
 * @author xh
 * @date 2021/9/6 14:37
 */
public class TimeUtils {

    /**
     * 把LocalDateTime 转成 2018-07-26T15:00:00+08:00(格式)
     *
     * @param ldt
     * @return
     */
    public static String getISO8601ToStr(LocalDateTime ldt) {

        ZoneOffset offset = ZoneOffset.of("+08:00");

        OffsetDateTime date = OffsetDateTime.of(ldt, offset);

        java.time.format.DateTimeFormatter dtf2 = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX");

        return date.format(dtf2);
    }
}
